//
//  CommentaryViewController.m
//  Astro
//
//  Created by ACER on 11/29/11.
//  Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//

#import "CommentaryViewController.h"
#import "TypeCommentaryVC.h"
#import "AstroAppDelegate.h"
#import "VCDataInput.h"

@implementation CommentaryViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
    
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
	appDelegate = (AstroAppDelegate*)[[UIApplication sharedApplication] delegate];
    // Do any additional setup after loading the view from its nib.
	
	//--- for chooses time.
	[self.view addSubview:appDelegate.dateInput.view];
	[appDelegate.dateInput setDatePickerMode:DatePickerModeTime];
	
}
//===========>>>
- (void) didRecieveDateFromVCDateInput:(NSString*)outputDate andDateString:(NSString*)_dateStr{
	NSLog(@"Date: %@   -  %@", outputDate, _dateStr);
	
	tf_TypeCommentary.text = [NSString stringWithFormat:@"%@ - %@", outputDate, _dateStr];
	
	[appDelegate.dateInput.view removeFromSuperview];
}

- (void) didCancelVCDateInput{
	
	NSLog(@"Cancel");
	[appDelegate.dateInput.view removeFromSuperview];
}

- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
	[self.view addSubview:appDelegate.dateInput.view];
	
	[appDelegate.dateInput setDatePickerMode:DatePickerModeDate];
		
	return NO;
}

- (void) viewWillAppear:(BOOL)animated{
	[appDelegate.dateInput setDelegate:self];  
}

//<<<===========



- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

//=========
- (IBAction) clickNextBtn {
	TypeCommentaryVC *viewTypeCommentary = [[TypeCommentaryVC alloc] initWithNibName:@"TypeCommentaryVC" bundle:nil
															  withTypeCommentary:typeCommentary andTime:time];
	
	[self.navigationController pushViewController:viewTypeCommentary animated:YES];
	
}

@end
